/**

 @Name: 案例

 */

layui.define(['layer', 'jquery'], function (exports) {
    let layer = layui.layer, $ = layui.jquery;
    let res = {
        responseFields:{
            statusName: 'errno' //数据状态的字段名称，默认：code
            , statusCode: 0 //成功的状态码，默认：0
            , msgName: 'errmsg' //状态信息的字段名称，默认：msg
            , countName: 'count' //数据总数的字段名称，默认：count
            , dataName: 'data' //数据列表的字段名称，默认：data
        },
        add: function (res) {
            if (res.errno === 0) {
                layer.confirm('成功', {
                    btn: ['继续添加', '返回']
                }, function () {
                    layer.closeAll();
                }, function () {
                    let index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                });
            } else {
                layer.msg(res.errmsg);
            }
        },
        modify: function (res) {
            if (res.errno === 0) {
                layer.alert('修改成功',function () {
                    layer.closeAll();
                    let index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                });

            } else {
                layer.msg(res.errmsg);
            }
        },
        delete: function (api) {
            $.get(api, function (res) {
                let index = parent.layer.getFrameIndex(window.name);
                if (res.errno === 0) {
                    layer.alert('删除成功');
                } else {
                    layer.msg(res.errmsg);
                }
            });

        },detail:function (api) {
            
        }

    }
    exports('res', res);
});